package com.harry.hr.biz.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import com.harry.hr.biz.MajorChangeBIZ;
import com.harry.hr.dao.MajorChangeDAO;
import com.harry.hr.entity.HumanFile;
import com.harry.hr.entity.MajorChange;
import com.harry.hr.utils.StringUtil;

public class MajorChangeBIZImpl implements MajorChangeBIZ{

	private MajorChangeDAO majorchangedao;
	public MajorChangeDAO getMajorchangedao() {
		return majorchangedao;
	}
	public void setMajorchangedao(MajorChangeDAO majorchangedao) {
		this.majorchangedao = majorchangedao;
	}
	public boolean addMajorChanger(MajorChange majorchange) {
		// TODO Auto-generated method stub
		try{
			majorchangedao.save(majorchange);
			return true;
		}catch(Exception ex)
		{
			ex.printStackTrace();
			return false;
		}
		
	}
	public List<HumanFile> getQueryHumanFile(HumanFile humanFile) {
		// TODO Auto-generated method stub
		DetachedCriteria criteria=DetachedCriteria.forClass(HumanFile.class);
		//状态为1表示为"正常"
		humanFile.setHumanFileStatus(Byte.parseByte("1"));
		
		if(!StringUtil.validateNull(humanFile.getFirstKindId())&&!humanFile.getFirstKindId().equals("---请选择---")){
			criteria.add(Restrictions.eq("firstKindId", humanFile.getFirstKindId()));
		}
		
		if(!StringUtil.validateNull(humanFile.getSecondKindId())&&!humanFile.getSecondKindId().equals("---请选择---")){
			criteria.add(Restrictions.eq("secondKindId", humanFile.getSecondKindId()));
		}
		
		if(!StringUtil.validateNull(humanFile.getThirdKindId())&&!humanFile.getThirdKindId().equals("---请选择---")){
			criteria.add(Restrictions.eq("thirdKindId", humanFile.getThirdKindId()));
		}		
		
		if(!StringUtil.validateNull(humanFile.getHumanMajorKindId())&&!humanFile.getHumanMajorKindId().equals("---请选择---")){
			criteria.add(Restrictions.eq("humanMajorKindId", humanFile.getHumanMajorKindId()));
		}
		
		if(!StringUtil.validateNull(humanFile.getHumanMajorId())&&!humanFile.getHumanMajorId().equals("---请选择---")){
			criteria.add(Restrictions.eq("humanMajorId", humanFile.getHumanMajorId()));
		}
		
		
		
		if(null!=humanFile.getQueryBeginDate()&&null!=humanFile.getQueryEndDate()){
			criteria.add(Restrictions.between("registTime", humanFile.getQueryBeginDate(), humanFile.getQueryEndDate()));
		}
		
		List<HumanFile> hList=majorchangedao.getHumanFile(criteria);
		
		return hList;
	}
	

}
